
export class BootScene extends Phaser.Scene {
    
    private loadingBar: Phaser.GameObjects.Graphics;
    private progressBar: Phaser.GameObjects.Graphics;
    
    constructor() {
        super('BootScene');
    }

    preload() {
        console.log('see run boot scene');
        
        this.cameras.main.setBackgroundColor(0x000000);
        
        this.loadingBar = this.add.graphics()
            .fillStyle(0xffffff, 1)
            .fillRect(
                this.cameras.main.width / 4 -2,
                this.cameras.main.height / 2 - 18,
                this.cameras.main.width / 2 + 4,
                20
            )
        ;

        this.progressBar = this.add.graphics()
        ;

        this.load.on('progress', 
            (value: number) => {

            this.progressBar.clear();
            this.progressBar.fillStyle(0x88e453, 1);
            this.progressBar.fillRect(
                this.cameras.main.width / 4,
                this.cameras.main.height / 2 - 16,
                (this.cameras.main.width /2) * value,
                16
            )
        })

        
        this.load.on(
            'complete',
            () => {
                this.progressBar.destroy();
                this.loadingBar.destroy();
            },
            this
        );
        
        this.load.audio("sound-start", "assets/sound/sound-start.mp3");
		this.load.audio("sound-fire", "assets/sound/sound-fire2.mp3");
		this.load.audio("sound-hit", "assets/sound/sound-fire.mp3");
		this.load.audio("sound-boom1", "assets/sound/sound-boom1.mp3");
		this.load.audio("sound-boom2", "assets/sound/sound-boom2.mp3");
		this.load.audio("sound-win", "assets/sound/sound-win.mp3");
		this.load.audio("sound-over", "assets/sound/sound-over.mp3");

        
        this.load.image("title", "assets/img/battlecity2.png")
        this.load.image("over", "assets/img/gameover.png");
        this.load.image("over-2", "assets/img/gameover2.png");


        this.load.spritesheet("tank", "assets/img/player1.png", {frameWidth: 16, frameHeight: 16});  
		this.load.spritesheet("enemy", "assets/img/enemy.png", {frameWidth: 16, frameHeight: 16}); 
		this.load.spritesheet("button-arrow", "assets/img/button-arrow.png", {frameWidth: 32, frameHeight: 32});  
		this.load.spritesheet("button-a", "assets/img/button-a.png",{frameWidth: 48, frameHeight: 48});


        this.load.spritesheet("bonus", "assets/img/bonus.png", {frameWidth: 16, frameHeight: 15}); 
        this.load.spritesheet("bore", "assets/img/bore.png", {frameWidth: 16, frameHeight: 16});  
        this.load.spritesheet("bullet", "assets/img/bullet.png", {frameWidth: 6, frameHeight: 6}); 
        
        this.load.image("explode1", "assets/img/explode1.png");
		this.load.image("explode2", "assets/img/explode2.png");
		this.load.tilemapTiledJSON("levels", "assets/img/levels.json");
		this.load.image("tile", "assets/img/tile.png");
    }

    
    create() {
        this.scene.start('MenuScene');
    }
}